package com.own.core.app;

import org.apache.wicket.authroles.authentication.AuthenticatedWebSession;
import org.apache.wicket.authroles.authorization.strategies.role.Roles;
import org.apache.wicket.protocol.http.WebSession;
import org.apache.wicket.request.Request;

import com.own.core.CoreFacade;
import com.own.core.object.admin.User;
import com.own.util.AuthorizationPages;
 

public class OwnSession extends AuthenticatedWebSession {

	User user;
	AuthorizationPages AuthPage;

	public OwnSession(Request request) {
		super(request);
	}

	public void setUser(User user) {
		this.user = user;

		AuthPage = new AuthorizationPages(user);

	}

	public User getUser() {
		return user;

	}

	public AuthorizationPages getAuthPage() {
		return AuthPage;
	}

	@Override
	public boolean authenticate(final String username, final String password) {
		user = CoreFacade.authorizedUser("admin", "test");

		return true;
	}

	@Override
	public Roles getRoles() {
		 
		if (isSignedIn())
		{
			// If the user is signed in, they have these roles
			return new Roles(Roles.ADMIN);
		}
		return null;
	 
	}

}
